package com.test

import org.grails.datastore.gorm.finders.MethodExpression.InList;


class Race {
	String name
	Date startDate
	String city
	String state
	BigDecimal distance
	BigDecimal cost
	Integer maxRunners = 100000
	
	static searchable = true
	
    static constraints = {
		name(blank:false, maxSize:50)
		startDate(validator: {return (it > new Date())})
		city()
		state(InList:["GA", "NC", "SC", "VA"])
		distance(min:0.0)
		cost(min:0.0, max:100.0) 
		maxRunners(min:0, max:100000) 
    }
	
	static hasMany = [registrations: Registration]
	
	String toString (){
		return "${name}, ${startDate.format('MM/dd/yyyy')}"
	}
	
	static mapping = {
		sort "startDate"
	}
}
